<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>添加订单-后台管理系统-Admin 1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/weadmin.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/treeselect.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <%--<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/treeselect.js" charset="utf-8"></script>--%>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="weadmin-body">
    <form class="layui-form"   lay-filter="pushform" >

        <div class="layui-form-item">
            <label class="layui-form-label">
                用户名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="uname" name="uname" lay-verify="required|nikename"  autocomplete="off" class="layui-input"  value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                邮箱
            </label>
            <div class="layui-input-inline">
                <input type="text" id="uemail" name="uemail" lay-verify="uemail" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label  class="layui-form-label">
                性别
            </label>
            <div class="layui-input-inline">
                <input type="text" id="sex" name="sex" lay-verify="sex" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
<%--        <div class="layui-form-item">
            <label  class="layui-form-label">
                手机
            </label>
            <div class="layui-input-inline">
                <input type="text" id="utel" name="utel" lay-verify="required|phone" autocomplete="off" class="layui-input" value="">

                                <input type="hidden"   id="uid"  name="uid" value="<%=request.getParameter("uid")%>" />
            </div>
        </div>--%>


        <div class="layui-form-item">
            <label  class="layui-form-label">
                手机
            </label>
            <div class="layui-input-inline">
                <input type="text" id="utel" name="utel" lay-verify="rutelequired|phone" autocomplete="" class="layui-input">
                <input type="hidden"   id="uid"  name="uid" value="<%=request.getParameter("uid")%>" />
            </div>
        </div>

        <div class="layui-form-item">
            <label for="add" class="layui-form-label">
            </label>
            <button id="add" class="layui-btn" lay-filter="add" lay-submit="">增加/编辑</button>
        </div>
    </form>
</div>
<script>
    layui.extend({
        admin: '${pageContext.request.contextPath}/static/js/admin',
        treeselect: '${pageContext.request.contextPath}/static/js/treeselect'
    });





    layui.use(['form', 'admin','layer','layedit','treeselect','jquery'], function () {
        var form = layui.form,
            admin = layui.admin,
            layer = layui.layer,
            layedit = layui.layedit,
           /* treeselect = layui.treeselect,*/
            $=layui.jquery;



        function  formrender(){
            form.render();

        }

        $(function () {
            $.ajax({
                url:"${pageContext.request.contextPath}/item/edit2",
                data:{"uid":$("#uid").val()},
                dataType:"json",
                type:"post",
                success:function(d){
                    if(d!= null){
                        $("#uid").val(d.uid);
                        $("#uemail").val(d.uemail);
                        $("#uname").val(d.uname);
                        $("#utel").val(d.utel);
                        $("#sex").val(d.sex);
                    }else{


                    }
            }
            });
        });




        //监听提交

        form.on('submit(add)', function (data) {


                $.ajax({
                    url:"${pageContext.request.contextPath}/user/update",
                    data:data.field,
                    dataType:"json",
                    type:"post",
                    success:function(d){
                        if(d.i==1){
                            window.location.href="${pageContext.request.contextPath}/user/list";
                        }
                    }
                })
           /* }else{

                $.ajax({
                    url:"${pageContext.request.contextPath}/user/insert",
                    data:data.field,
                    dataType:"json",
                    type:"post",
                    success:function(d){
                        if(d.d==1){
                            window.location.href="${pageContext.request.contextPath}/user/list";
                        }
                    }
                })
            }*/

        });


    });
</script>
</body>

</html>